﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    abstract class  father {
        private string name;
        public string Name { get { return name; } set{ name = value; } }
        abstract public void rock ();
        abstract public void scissor();
        abstract public void cloth();
        public father() { }
        public father(string name)
        {
            this.Name = name;
        }


    }
    class Liubei : father
    {
        public Liubei() { }
        public Liubei(string name) : base(name)
        {
        }

        public override void cloth()
        {
            Console.WriteLine("{0} 出拳：布", this.Name);
        }

        public override void rock()
        {
            Console.WriteLine("{0} 出拳：拳头", this.Name);
        }

        public override void scissor()
        {
            Console.WriteLine("{0} 出拳：剪刀", this.Name);
        }
    }
    class Sunquan : father
    {
        public override void cloth()
        {
            Console.WriteLine("{0} 出拳：布", this.Name);
        }

        public override void rock()
        {
            Console.WriteLine("{0} 出拳：拳头", this.Name);
        }

        public override void scissor()
        {
            Console.WriteLine("{0} 出拳：剪刀", this.Name);
        }
    }
    class Caochao : father
    {
        public override void cloth()
        {
            Console.WriteLine("{0} 出拳：布", this.Name);
        }

        public override void rock()
        {
            Console.WriteLine("{0} 出拳：拳头", this.Name);
        }

        public override void scissor()
        {
            Console.WriteLine("{0} 出拳：剪刀", this.Name);
        }
    }
    class Player : father
    {

        public override void cloth()
        {
            Console.WriteLine("{0} 出拳：布",this.Name);
        }

        public override void rock()
        {
            Console.WriteLine("{0} 出拳：拳头",this.Name);
        }

        public override void scissor()
        {
            Console.WriteLine("{0} 出拳：剪刀", this.Name);
        }
    }
    class Speak {
        public void go() {
            Console.WriteLine("请出拳：1.剪刀 2.石头 3.布");
        }
        public void isgo() {
            Console.WriteLine("是否继续？（y/n）");
        }
        public void win() {
            Player player = new Player();
            Console.WriteLine("恭喜，{0}赢了",player.Name);
        }
        public void lose()
        {
            Player player = new Player();
            Console.WriteLine("笨蛋，{0}输了", player.Name);
        }
        public void dogfall()
        {
            Console.WriteLine("真衰！嘿嘿！等着瞧");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {

            home();
 
        }

        private static void home()
        {
            Console.WriteLine("-----------------欢迎进入游戏世界--------------");
            Console.WriteLine("***************************************");
            Console.WriteLine("***************猜拳，开始**************");
            Console.WriteLine("***************************************");
            Console.WriteLine("出拳规则：1.剪刀 2.石头 3.布");
            Console.WriteLine("选择对方角色：1.刘备 2.孙权 3.曹操");
            string key = Console.ReadLine();
            switch (key)
            {
                case "1":
                    Liubei liubei = new Liubei("刘备");
                    Console.WriteLine("请输入你的姓名：");
                    string str = Console.ReadLine();
                    Player player = new Player();
                    player.Name = str;
                    Console.WriteLine("{0} vs {1} 对战", player.Name, liubei.Name);
                    Console.WriteLine("开始游戏吗？(y/n)");
                    string str1 = Console.ReadLine();
                    switch (str1)
                    {
                        case "y":

                            game(player, liubei);
                            break;
                        case "n":
                            break;
                        default:
                            break;
                    }
                    break;
                case "2":
                    Sunquan sunquan = new Sunquan();
                    sunquan.Name = "孙权";
                    Console.WriteLine("请输入你的姓名：");
                    string s1 = Console.ReadLine();
                    Player player1 = new Player();
                    player1.Name = s1;
                    Console.WriteLine("{0} vs {1} 对战", player1.Name, sunquan.Name);
                    Console.WriteLine("开始游戏吗？(y/n)");
                    string s11 = Console.ReadLine();
                    switch (s11)
                    {
                        case "y":

                            game(player1, sunquan);
                            break;
                        case "n":
                            break;
                        default:
                            break;
                    }
                    break;
                case "3":
                    Caochao caochao = new Caochao();
                    caochao.Name = "曹操";
                    Console.WriteLine("请输入你的姓名：");
                    string s2 = Console.ReadLine();
                    Player player2 = new Player();
                    player2.Name = s2;
                    Console.WriteLine("{0} vs {1} 对战", player2.Name, caochao.Name);
                    Console.WriteLine("开始游戏吗？(y/n)");
                    string s22 = Console.ReadLine();
                    switch (s22)
                    {
                        case "y":

                            game(player2, caochao);
                            break;
                        case "n":
                            break;
                        default:
                            break;
                    }
                    break;
                default:
                    break;
            }
        }

        private static void game(Player player, Liubei liubei)
        {
            int count = 0;
            int win = 0;
            int win2 = 0;
            Random random = new Random();
            Speak speak = new Speak();
          a:  speak.go();
            string key=Console.ReadLine();
            switch (key)
            {
                case "1":
                    int num = random.Next(1, 4);
                    switch (num)
                    {
                        case 1:
                            player.scissor();
                            liubei.scissor();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player,liubei,win,win2,count);
                                    break;
                                default:
                                    break;
                            }
                            break;
                        case 2:
                            player.scissor();
                            liubei.rock();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }

                            break;
                        case 3:
                            player.scissor();   
                            liubei.cloth();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string y = Console.ReadLine();
                            switch (y)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                    break;
                case "2":
                    int num2 = random.Next(1, 4);
                    switch (num2)
                    {
                        case 1:
                           
                            player.rock();
                            liubei.scissor();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;
                          
                        case 2:
                            player.rock();
                            liubei.rock();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;
                           
                        case 3:
                            player.rock();
                            liubei.cloth();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string c = Console.ReadLine();
                            switch (c)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                    break;
                case "3":
                    int num3 = random.Next(1, 4);
                    switch (num3)
                    {
                        case 1:

                            player.cloth();
                            liubei.scissor();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            
                            break;
                        case 2:
                            player.cloth();
                            liubei.rock();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                          

                            break;
                        case 3:
                            player.cloth();
                            liubei.cloth();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string c = Console.ReadLine();
                            switch (c)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, liubei, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;
 

                        default:
                            break;
                    }
                    break;


                default:
                    break;
            }
        }
        private static void game(Player player, Caochao caochao)
        {
            int count = 0;
            int win = 0;
            int win2 = 0;
            Random random = new Random();
            Speak speak = new Speak();
        a: speak.go();
            string key = Console.ReadLine();
            switch (key)
            {
                case "1":
                    int num = random.Next(1, 4);
                    switch (num)
                    {
                        case 1:
                            player.scissor();
                            caochao.scissor();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;
                        case 2:
                            player.scissor();
                            caochao.rock();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }

                            break;
                        case 3:
                            player.scissor();
                            caochao.cloth();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string y = Console.ReadLine();
                            switch (y)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                    break;
                case "2":
                    int num2 = random.Next(1, 4);
                    switch (num2)
                    {
                        case 1:

                            player.rock();
                            caochao.scissor();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        case 2:
                            player.rock();
                            caochao.rock();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        case 3:
                            player.rock();
                            caochao.cloth();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string c = Console.ReadLine();
                            switch (c)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                    break;
                case "3":
                    int num3 = random.Next(1, 4);
                    switch (num3)
                    {
                        case 1:

                            player.cloth();
                            caochao.scissor();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }

                            break;
                        case 2:
                            player.cloth();
                            caochao.rock();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }


                            break;
                        case 3:
                            player.cloth();
                            caochao.cloth();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string c = Console.ReadLine();
                            switch (c)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, caochao, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;


                        default:
                            break;
                    }
                    break;


                default:
                    break;
            }
        }
        private static void game(Player player, Sunquan sunquan)
        {
            int count = 0;
            int win = 0;
            int win2 = 0;
            Random random = new Random();
            Speak speak = new Speak();
        a: speak.go();
            string key = Console.ReadLine();
            switch (key)
            {
                case "1":
                    int num = random.Next(1, 4);
                    switch (num)
                    {
                        case 1:
                            player.scissor();
                            sunquan.scissor();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;
                        case 2:
                            player.scissor();
                            sunquan.rock();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }

                            break;
                        case 3:
                            player.scissor();
                            sunquan.cloth();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string y = Console.ReadLine();
                            switch (y)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                    break;
                case "2":
                    int num2 = random.Next(1, 4);
                    switch (num2)
                    {
                        case 1:

                            player.rock();
                            sunquan.scissor();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        case 2:
                            player.rock();
                            sunquan.rock();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        case 3:
                            player.rock();
                            sunquan.cloth();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string c = Console.ReadLine();
                            switch (c)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                    break;
                case "3":
                    int num3 = random.Next(1, 4);
                    switch (num3)
                    {
                        case 1:

                            player.cloth();
                            sunquan.scissor();
                            speak.lose();
                            win2++;
                            count++;
                            speak.isgo();
                            string a = Console.ReadLine();
                            switch (a)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }

                            break;
                        case 2:
                            player.cloth();
                            sunquan.rock();
                            speak.win();
                            win++;
                            count++;
                            speak.isgo();
                            string b = Console.ReadLine();
                            switch (b)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }


                            break;
                        case 3:
                            player.cloth();
                            sunquan.cloth();
                            speak.dogfall();
                            count++;
                            speak.isgo();
                            string c = Console.ReadLine();
                            switch (c)
                            {
                                case "y":
                                    goto a;
                                    break;
                                case "n":
                                    end(player, sunquan, win, win2, count);
                                    break;
                                default:
                                    break;
                            }
                            break;


                        default:
                            break;
                    }
                    break;


                default:
                    break;
            }
        }
        private static void end(Player player,Liubei liubei, int win, int win2, int count)
        {
            Console.WriteLine("===============================================");
            Console.WriteLine("{0} vs {1} 对战", player.Name, liubei.Name);
            Console.WriteLine("对战次数:{0}", count);
            Console.WriteLine();
            Console.WriteLine("姓名*********得分");
            Console.WriteLine("{0}          {1}", player.Name, win);
            Console.WriteLine("{0}          {1}", liubei.Name, win2);
            if (win > win2) { Console.WriteLine("结果： {0}赢，{1}笨蛋",player.Name,liubei.Name); }
            if (win == win2) { Console.WriteLine("结果：{0}和{1} 平局", player.Name, liubei.Name); }
            if (win < win2) { Console.WriteLine("结果： {0}赢，{1}笨蛋", liubei.Name, player.Name); }
            Console.WriteLine("是否继续下一局？（y/n）");
            string key = Console.ReadLine();
            switch (key)
            {
                case "y":
                    home();
                    break;
                case "n":
                    break;
                default:
                    break;
            }
  
        }
        private static void end(Player player, Sunquan sunquan, int win, int win2, int count)
        {
            Console.WriteLine("===============================================");
            Console.WriteLine("{0} vs {1} 对战", player.Name, sunquan.Name);
            Console.WriteLine("对战次数:{0}", count);
            Console.WriteLine();
            Console.WriteLine("姓名*********得分");
            Console.WriteLine("{0}          {1}", player.Name, win);
            Console.WriteLine("{0}          {1}", sunquan.Name, win2);
            if (win > win2) { Console.WriteLine("结果： {0}赢，{1}笨蛋", player.Name, sunquan.Name); }
            if (win == win2) { Console.WriteLine("结果：{0}和{1} 平局", player.Name, sunquan.Name); }
            if (win < win2) { Console.WriteLine("结果： {0}赢，{1}笨蛋", sunquan.Name, player.Name); }
            Console.WriteLine("是否继续下一局？（y/n）");
            string key = Console.ReadLine();
            switch (key)
            {
                case "y":
                    home();
                    break;
                case "n":
                    break;
                default:
                    break;
            }

        }
        private static void end(Player player,Caochao caochao, int win, int win2, int count)
        {
            Console.WriteLine("===============================================");
            Console.WriteLine("{0} vs {1} 对战", player.Name, caochao.Name);
            Console.WriteLine("对战次数:{0}", count);
            Console.WriteLine();
            Console.WriteLine("姓名*********得分");
            Console.WriteLine("{0}          {1}", player.Name, win);
            Console.WriteLine("{0}          {1}", caochao.Name, win2);
            if (win > win2) { Console.WriteLine("结果： {0}赢，{1}笨蛋", player.Name, caochao.Name); }
            if (win == win2) { Console.WriteLine("结果：{0}和{1} 平局", player.Name, caochao.Name); }
            if (win < win2) { Console.WriteLine("结果： {0}赢，{1}笨蛋", caochao.Name, player.Name); }
            Console.WriteLine("是否继续下一局？（y/n）");
            string key = Console.ReadLine();
            switch (key)
            {
                case "y":
                    home();
                    break;
                case "n":
                    break;
                default:
                    break;
            }

        }
   


    }
}
